<template>
	<!-- 新增维修类型-->
	<el-dialog :close-on-click-modal='false' :append-to-body='true' :before-close='close' :close-on-press-escape='false'
	 title="新增维修类型" :visible.sync="addTypeShowNow">
		<el-form :model="form" :rules="rules" ref="form" v-loading='isLoading' label-width="100px">
			<!-- <div class="textLeft titleMessNow">单位信息</div> -->
			<el-row>
				<el-col :span="10">
					<el-form-item label="维修类型:" prop="mainType">
						<el-input type="text" v-model="form.mainType" placeholder="请输入维修类型" clearable size='mini'></el-input>
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>

		<div slot="footer" class="dialog-footer">
			<el-button @click="close">取 消</el-button>
			<el-button type="primary" @click="submit('form')" v-loading='ensureBtn'>确 定</el-button>
		</div>
		
	</el-dialog>
</template>

<script>
	import {
		mainType
	} from './rules.js'
	import {
		axiosPost,
		axiosGet,
		loadFn,
		axiosChange,
	} from "@/common.js"
	export default {
		props:['addTypeShowNow'],
		data() {
			return {
				ensureBtn: false,
				isLoading: false,
				form: {
					mainType: '',
				},
				rules: {
					mainType,
				},
			}
		},
		methods: {
			//提交
			submit(ruleForm) {
				this.$refs[ruleForm].validate((valid) => {
					if (valid) {
						this.ensureBtn = true
						let data = {
							name:this.form.mainType
						}
						axiosPost('/manu/elevator/type/', data, (res) => {
							this.ensureBtn = false
							if (res.code == 0) {
								this.$message({
									type: 'success',
									message: '操作成功'
								})
								this.$emit('upMainTypeDateList')
							} else {
								this.$message.error(res.detail.result)
							}
						})
					} else {
						console.log('error submit!!');
						return false;
					}
				});
			},
			//取消
			close() {
				this.$emit('closeAddTypeDialog')
			}
		}
	}
</script>

<style>
</style>
